#include <iostream>

using namespace std;

#include "stateagent.h"
//#include "State/sm_state_machine.h"

int main()
{
    cout << "Hello World!" << endl;


    int state_check_result = 0;
    int iResult = OK;

//    if(iResult == OK)
//    {
//        iResult = sm_state_machine_create();
//    }

//    if(iResult == OK)
//    {
//        iResult = sm_state_machine_check_transition(SM_EVENT_INITIALIZE,&state_check_result);
//        if(iResult == OK && state_check_result != OK)
//        {
//            iResult = state_check_result;
//        }
//    }
//    if(iResult == OK)
//    {
//        iResult =  sm_state_machine_check_transition(SM_EVENT_GET_RESULT_EMPTY,&state_check_result);
//        if(iResult == OK && state_check_result != OK)
//        {
//            iResult = state_check_result;
//        }
//    }

    if(iResult == OK)
    {
        iResult = stateagent_create();
    }

    if(iResult == OK)
    {
        printf("stateagent_create() OK\n");
        iResult = stateagent_terminate();
    }

    if(iResult == OK)
    {
        printf("stateagent_terminate() OK\n");
        iResult = stateagent_initialize();
    }

    if(iResult == OK)
    {
        printf("stateagent_initialize() OK\n");
    }

    SM_QUEUE_STATE_ENUM queue_state = QUEUE_STATE_MIN;
    for(int actionId=1; actionId<15 && (iResult==OK); actionId++)
    {
        iResult = stateagent_queue(actionId, &queue_state);
        if(iResult == OK)
        {
            printf("actionId=%d, stateagent_queue() OK\n",actionId);
        }
        if(queue_state == QUEUE_STATE_FULL)
        {
            break;
        }
    }

    int actionId = -1;
    do
    {
        iResult = stateagent_get_result(&actionId, &queue_state);
        if(QUEUE_STATE_EMPTY == queue_state)
        {
            break;
        }
        if(iResult == OK)
        {
            printf("actionId=%d, stateagent_get_result() OK\n",actionId);
        }
    }while(OK==iResult);

    printf("iResult=0x%x\n",iResult);


    return 0;
}
